package com.stats.ultimate;

import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Menu extends Activity {
	// Declare variable to hold database helper and sqlite database
	SQLiteDatabase db;
	DatabaseHelper db_helper;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        
        // Instantiate new database helper
        db_helper = new DatabaseHelper(this);
        
        // Create database if it doesn't already exist
        db = db_helper.getWritableDatabase();
        
        // Close database
        db.close();
        
        // Instantiate three buttons to launch three separate activities
        Button teams = (Button) findViewById(R.id.teams);
        Button game = (Button) findViewById(R.id.game);
        Button stats = (Button) findViewById(R.id.stats);
        
        // Set onClickListener for teams button
        teams.setOnClickListener(new View.OnClickListener() {
			// Override onClick function
			@Override
			public void onClick(View arg0) {
				// Start teams activity
				Intent start_teams = new Intent(getApplicationContext(), Teams.class);
				startActivity(start_teams);
			}
		});
        
        // Set onClickListener for game button
        game.setOnClickListener(new View.OnClickListener() {
			// Override onClick function
			@Override
			public void onClick(View arg0) {
				// Start choose activity with argument of 1
				Intent start_choose = new Intent(getApplicationContext(), Choose.class);
				start_choose.putExtra("arg", 1);
				startActivity(start_choose);
			}
		});
        
        // Set onClickListener for stats button
        stats.setOnClickListener(new View.OnClickListener() {
			// Override onClick function
			@Override
			public void onClick(View v) {
				// Start choose activity with argument of 2
				Intent start_choose = new Intent(getApplicationContext(), Choose.class);
				start_choose.putExtra("arg", 2);
				startActivity(start_choose);
			}
		});
    }
}